#pragma once
#include "std.h"

struct Vec3
{
    float x, y, z;

    Vec3() : x(0.f), y(0.f), z(0.f) {}
    Vec3(const float x_in, const float y_in, const float z_in) : x(x_in), y(y_in), z(z_in) {}
    Vec3(const Vec3 & in) { x = in.x; y = in.y, z = in.z; }
    Vec3 & operator=(const Vec3 & in) { x = in.x; y = in.y, z = in.z; return *this; }
};

class GridMeshXZ
    // A grid mesh in the XZ plane at 0,0,0 by default.
{
    float cellSize;
    int cellsX;
    int cellsZ;
    Vec3* verts;
    // Vertex array, allocated on this class' construction.
    int nVerts;
    int nTris;

    int*  index;
    // Indices into this class' vertex array, defining a triangle mesh grid.
    int indexSize;

public:
    GridMeshXZ(float cellSize, int cellsX, int cellsZ);
    ~GridMeshXZ();
    int getIndexSize() { return indexSize; }
    Vec3 & operator[](int i);
private:
    void allocVertexBuffer(float cellSize, int cellsX, int cellsZ);
    void allocIndexBuffer()
};